<?php
class import_etao_data extends PHPUnit_Framework_TestCase{

    public function setUp()
    {
		$this->object = kernel::single('tbdata_api_tbapi');
		$this->cat_model = app::get('tbdata')->model('cats');
		$this->fetch_props_model = app::get('tbdata')->model('fetch_props');
		$this->product_model = app::get('tbdata')->model('product');
		$this->goods_model = app::get('tbdata')->model('goods');
    }

    public function testGetcat(){
		$db = kernel::database();

		$fp = fopen('d:\1512_etao.csv', 'r');
		$i = 0;
		while (($data = fgetcsv($fp, 10000, ",")) !== FALSE) {
			if($i==0){
				$cols = $data;
				$i++;
				continue;
			}
			
			foreach($data as $key=>$value){
				$tmp_data[$cols[$key]] = $value;
			}
			$tmp_data['goods_name'] = $tmp_data['title'];
			$logo = $tmp_data['merchant_logo'];
			unset($tmp_data['merchant_logo']);
			$tmp_data['cid'] = 1512;
			$this->goods_model->save($tmp_data);
			unset($tmp_data['id']);
		}

	}
}
